package com.yanqu.road.server.cmd.activity.dafuweng;

import com.yanqu.road.pb.monopoly.MonopolyProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.dafuweng.DaFuWengMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_DA_FU_WENG_BATTLE_BOSS_FROM_CROSS, desc = "跨服打boss返回")
public class DaFuWengBattleBossFromCrossCmd extends AbstractCommand {

    private int type;
    private int buffTimes;
    private String cost = "";
    private int activityId;

    private MonopolyProto.BossDataMsg bossDataMsg = null;
    private int realDamage;
    private boolean isKill;
    private String reward;
    private long consumeYongBingCardNum;
    private long preReduceYongBingCardNum;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        MonopolyProto.CrossBattleBossRespMsg respMsg = MonopolyProto.CrossBattleBossRespMsg.parseFrom(packet.getBytes());
        ret = respMsg.getRet();
        type = respMsg.getType();
        buffTimes = respMsg.getBuffTimes();
        cost = respMsg.getCost();
        activityId = respMsg.getActivityId();
        preReduceYongBingCardNum = respMsg.getPreReduceYongBingCardNum();
        if (respMsg.hasBossData()) {
            bossDataMsg = respMsg.getBossData();
        }
        if (ret == 0) {
            bossDataMsg = respMsg.getBossData();
            realDamage = respMsg.getRealDamage();
            isKill = respMsg.getIsKill();
            reward = respMsg.getReward();
            consumeYongBingCardNum = respMsg.getConsumeYongBingCardNum();
        }
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        DaFuWengMgr.handleBattleBossResult(ret, activityId, player, type, realDamage, isKill, buffTimes, cost, reward, preReduceYongBingCardNum,consumeYongBingCardNum, bossDataMsg);
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
